package com.mdd.config;

import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.Filter;

public class WebInitConfig extends AbstractAnnotationConfigDispatcherServletInitializer {

    // 加载 spring 容器配置
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{SpringConfig.class};
    }

    // 加载 springMVC 容器配置
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{SpringMvcConfig.class};
    }

    // 设置哪些请求路径归属 springMVC 处理
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    // 解决中文乱码问题 (post)
   /* @Override
    protected Filter[] getServletFilters() {
        CharacterEncodingFilter filter = new CharacterEncodingFilter();
        filter.setEncoding("UTF-8");
        return new Filter[]{filter};
    }*/


}
